package top.iridescent.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import top.iridescent.dao.model.request.MhPetQuery;
import top.iridescent.entity.MhPet;
import top.iridescent.service.impl.MhPetServiceImpl;
import top.iridescent.util.PageUtils;
import top.iridescent.model.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 
 *
 * @author 
 * @email 
 * @date 2021-09-03 17:01:36
 */
@RestController
@Api(tags = "MhPet")
@RequestMapping("mh/mhpet")
@CrossOrigin
public class MhPetController  {
    @Autowired
    private MhPetServiceImpl service;

    /**
     * 列表
     */
    @ApiOperation(value = "分页检索", notes = "")
    @PostMapping("/list")
    //@RequiresPermissions("mh:mhpet:list")
    public Result findPage(@RequestBody MhPetQuery param){
        return service.findPage(PageUtils.getPage(param), param);
    }


    /**
     * 信息
     */
    @ApiOperation(value = "单个检索 ", notes = "")
    @GetMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhpet:info")
    public Result getById(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        return service.getById(objId);
    }

    /**
     * 保存
     */
    @ApiOperation(value = "新增", notes = "")
    @PostMapping(value = "", produces = "application/json")
    //@RequiresPermissions("mh:mhpet:save")
    public Result save(@RequestBody MhPet param){
        //param.setOperId(((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUserId());
        return service.saveInfo(param);
    }

    /**
     * 修改
     */
    @ApiOperation(value = "更新", notes = "")
    @PutMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhpet:update")
    public Result update(@ApiParam(name = "objId", value = "") @PathVariable Long objId,@RequestBody MhPet param){
        param.setId(objId);
        //param.setOperId(((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUserId());
        return service.update(param);
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除", notes = "")
    @DeleteMapping(value = "/{objId}", produces = "application/json")
    //@RequiresPermissions("mh:mhpet:delete")
    public Result deleteById(@ApiParam(name = "objId", value = "") @PathVariable Long objId){
        return service.deleteById(objId);
    }

}
